home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekikoh Dennoh Club 1
/
Gekikoh Dennoh Club Vol. 1 (Japan).7z
/
Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin
/
kowin
/
archive
/
net
/
k20menus.lzh
/
k20exec.c
next >
Wrap
C/C++ Source or Header
|
1994-10-12
|
7KB
|
312 lines
/* Copyright 1992 H.Ogasawara (COR.) */
#include <corlib.h>
#include "k20menu.h"
int optins= FALSE;
int attr= 9;
extern int total;
extern NET_MENU *top;
extern unsigned char **lp;
extern int font;
extern int autoexit,
ncflag;
extern WindowID Awp, Bwp;
extern NET_MENU nnt;
extern char k20[];
extern short dspmode;
extern unsigned char NetMenuFile[],
NetLogFile[];
unsigned char Yankbuf[512]= {0};
short Cur= 0;
/*static short StRev= FALSE,
StPos;*/
#define RevLineON(a) (StRev=TRUE,StPos=(a),RevLine(a))
#define RevLineOFF(a) (StRev=FALSE,RevLine(a))
CurDraw( dbuf, pos )
DrawBuf *dbuf;
{
if( ncflag )
DrawSetLine( dbuf, 0,-1,0,-1, (attr&3), OptionLine );
else{
pos+= 3;
DrawSetLine( dbuf, 0,pos*font-4,35*font,pos*font,
(attr&3)|OptionXor, OptionFill );
}
}
RevLine( pos )
{
DrawBuf dbuf[1];
pos+= 2;
DrawSetLine( dbuf, 0,pos*font,35*font,pos*font+font-1,
(attr&3)|OptionXor, OptionFill );
WindowDraw( Bwp, dbuf, 1 );
}
EventExecB( wp, info )
WindowID wp;
EventInfo *info;
{
DrawBuf dbuf[80];
switch( info->option ){
case EventOpen:
return TRUE;
case EventClose:
Bwp= NULL;
WindowClose( wp );
return TRUE;
case EventRedraw: {
short i;
DrawBuf *dp= dbuf;
DrawSetClear( dp++, attr&AttrReverse?attr&3:0 );
DrawSetSymbol( dp++, 0, 0, lp[0], attr^AttrReverse, font );
DrawSetSymbol( dp++, 0,font, lp[1], attr|4, font );
for( i= 2 ; i< total ; i++ )
DrawSetSymbol(dp++,0,i*font,lp[i],attr,font);
CurDraw( dp++, Cur );
WindowDraw( wp, dbuf, dp-dbuf );
/* if( StRev )
RevLine(StPos);*/
}
return TRUE;
case EventMouseSwitch:
if( info->LeftON ){
if( (info->ShiftStat & 4) &&
(info->y < font*2 || info->x >= font) )
SetClipBoard( wp, info, lp, total+1, FALSE, font );
else if( info->y >= font*2 && info->x >= font ){
int i= info->y/font-2;
NET_MENU *net= (NET_MENU*)net_count(i);
if( !net )
return TRUE;
if( info->x < font*(24/2) ){
RevLine( i );
SendData( wp, info, UserString, net->name );
RevLine( i );
}else if( info->x >= font*(52/2) ){
RevLine( i );
SendData( wp, info, UserString, net->line );
RevLine( i );
}else{
RevLine( i );
SendData( wp, info, UserString, lp[i+2] );
RevLine( i );
}
}else if( info->y >= font*2 && info->x < font )
a_dial( info->y/font -2 );
}else if( info->y >= font*2 && info->RightON ){
int i= info->y/font-2;
p_menu( i );
}
return TRUE;
}
return FALSE;
}
ReRead()
{
/* DrawBuf dbuf[1];*/
int h, v;
if( Bwp )
WindowClose( Bwp );
/* DrawSetClear( dbuf, 1 );
WindowDraw( Awp, dbuf, 1 );*/
read_net( NetMenuFile );
log_count( NetLogFile );
make_line( top, lp );
WindowGetViewSize( Awp, &h, &v );
Bwp= WindowScrollOpen( 0, 0, h, v, Awp, font*70/2,
total*font, DirectionY|DirectionX, 16, font*2, EventExecB );
WindowRedraw( Awp );
}
EventExecA( wp, info )
WindowID wp;
EventInfo *info;
{
DrawBuf dbuf[2];
switch( info->option ){
case EventOpen:
read_net( NetMenuFile );
log_count( NetLogFile );
make_line( top, lp );
Bwp= WindowScrollOpen( 0, 0, info->h, info->v, wp, font*70/2,
total*font, DirectionY|DirectionX, 16, font*2, EventExecB );
WindowRedraw( Awp= wp );
return TRUE;
case EventClose:
WindowClose( wp );
WindowConnectionClose();
return TRUE;
case EventRedraw: {
int x, y;
WindowGetViewSize( wp, &x, &y );
DrawSetLine( dbuf, x-12, y-12, x-1, y-1, 1, OptionFill );
WindowDraw( wp, dbuf, 1 );
if( Bwp )
WindowSendEvent( Bwp, info );
}
return TRUE;
case EventResize:
WindowResize( Bwp, 0, 0, info->h, info->v );
WindowResize( wp, info->x, info->y, info->h, info->v );
return TRUE;
case EventMouseSwitch:{
int x, y;
WindowGetViewSize( wp, &x, &y );
if( info->LeftON && info->x > x-10 && info->x <= x &&
info->y > y-10 && info->y <= y )
WindowResizeOperation( wp, info );
else
WindowSendEvent( Bwp, info );
}
return TRUE;
case EventKey: {
short old= Cur;
int x, y, hy, i;
WindowGetViewSize( Bwp, &x, &y );
WindowGetHome( Bwp, &x, &hy );
if( (i= (Cur+1)*font) < hy )
WindowScroll( Bwp, 0, -(hy-i+font) );
else if( (i= (Cur+4)*font) > y+hy )
WindowScroll( Bwp, 0, (i-(y+hy)+font) );
switch( info->KeyCode ){
case '<':
case FuncKeyRollDown:
case FuncKey+1:
WindowScroll( Bwp, 0, -80*24 );
Cur= 0;
break;
case 'G':
case '>':
case FuncKeyRollUp:
case FuncKey+2:
WindowScroll( Bwp, 0, 80*24 );
Cur= total-3;
break;
case FuncKeyLeft:
case 'h':
case Ctrl('f'):
WindowScroll( Bwp, -16, 0 );
return TRUE;
case FuncKeyRight:
case 'l':
case Ctrl('b'):
case Ctrl('a'):
WindowScroll( Bwp, 16, 0 );
return TRUE;
case FuncKeyDown:
case 'j':
case Ctrl('n'):
case Ctrl('x'):
if( ++Cur >= total-2 )
Cur= total-3;
break;
case FuncKeyUp:
case 'k':
case Ctrl('p'):
case Ctrl('e'):
if( --Cur < 0 )
Cur= 0;
break;
case Ctrl('q'):
WindowSendSignal( WindowProcessID, SignalKill, NULL );
return TRUE;
case 'v':
case FuncKeyUnDo:
case FuncKey+6:
log_view( Cur, TRUE );
return TRUE;
case 'V':
case FuncKeyDel:
case FuncKey+7:
log_view( Cur, FALSE );
return TRUE;
case FuncKey+8:
case 'E':
log_edit( Cur );
return TRUE;
case FuncKey+19:
if( *Yankbuf ){
NET_MENU *net= (NET_MENU*)net_count( Cur );
ConsoleOpen();
ConsolePrint( "k20menu:行挿入中\r\n" );
optins= TRUE;
add_netlist( Yankbuf, net->key );
optins= FALSE;
ReRead();
ConsolePrint( "k20menu:正常終了\r\n" );
}
return TRUE;
case FuncKey+18:{
NET_MENU *net= (NET_MENU*)net_count( Cur );
char *p;
ConsoleOpen();
ConsolePrint( "k20menu:行削除中\r\n" );
p= (char*)astrcpy( Yankbuf, net->line );
if( p[-2] == '\n' )
p[-2]= '\0';
add_netlist( "", net->key );
ReRead();
ConsolePrint( "k20menu:正常終了\r\n" );
return TRUE;
}
case FuncKey+16: {
NET_MENU *net= (NET_MENU*)net_count( Cur );
if( net )
OpenDiag( info->x, info->y, net->line );
return TRUE;
}
case FuncKey+15:
OpenDiag( info->x, info->y, "" );
return TRUE;
case Ctrl('u'):
case Ctrl('s'):
case FuncKey+4:
case FuncKeyHome:
dspmode= (dspmode+1)%6;
goto setdisp;
case Ctrl('d'):
case FuncKey+3:
dspmode= (dspmode+5)%6;
#if 0
goto setdisp;
case FuncKey+3:
case FuncKey+4:
case FuncKey+5:
case FuncKey+6:
case FuncKey+7:
case FuncKey+8:
dspmode= info->KeyCode-(FuncKey+3);
#endif
setdisp:
make_line( top, lp );
WindowRedraw( wp );
return TRUE;
case ' ':
case Ctrl('m'):
case Ctrl('j'):
a_dial( Cur );
default:
return TRUE;
}
if( old == Cur )
break;
CurDraw( dbuf, old );
CurDraw( dbuf+1, Cur );
WindowDraw( Bwp, dbuf, 2 );
}
return TRUE;
case EventIconify:
IconEnt( wp, "DialMenu", AttrDefault, 12 );
return TRUE;
}
return FALSE;
}